package com.ssy.lingxi.workflow.api.feign;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.workflow.api.model.vo.request.*;
import com.ssy.lingxi.workflow.api.model.vo.response.ComplexTaskCompleteVO;
import com.ssy.lingxi.workflow.api.model.vo.response.ComplexTaskDefVO;
import com.ssy.lingxi.workflow.api.model.vo.response.SimpleProcessDefVO;
import com.ssy.lingxi.workflow.api.model.vo.response.SimpleTaskCompleteVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.validation.Valid;
import java.util.List;

/**
 * 任务执行、流程步骤查询接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-04-30
 */
@FeignClient(name = "workflow-service")
public interface ProcessFeign {

    /**
     * （各种流程通用）启动流程
     * @param startVO 接口参数
     * @return 启动结果
     */
    @RequestMapping(value = "/workflow/process/start", method = RequestMethod.POST)
    Wrapper<ComplexTaskCompleteVO> startProcess(@RequestBody @Valid TaskStartVO startVO);

    /**
     * （各种流程通用）启动流程后，执行第一个Task
     * @param startVO 接口参数
     * @return 执行结果
     */
    @RequestMapping(value = "/workflow/process/start/exec/first", method = RequestMethod.POST)
    Wrapper<ComplexTaskCompleteVO> startProcessThenCompleteFirstTask(@RequestBody @Valid TaskStartVO startVO);

    /**
     * （各种流程通用）执行流程步骤
     * @param executeVO 接口参数
     * @return 执行结果
     */
    @RequestMapping(value = "/workflow/process/exec", method = RequestMethod.POST)
    Wrapper<ComplexTaskCompleteVO> completeTask(@RequestBody @Valid TaskExecuteVO executeVO);

    /**
     * （各种流程通用）连续执行流程步骤
     * @param executeVO 接口参数
     * @return 执行结果
     */
    @RequestMapping(value = "/workflow/process/exec/serial", method = RequestMethod.POST)
    Wrapper<ComplexTaskCompleteVO> completeSerialTasks(@RequestBody @Valid SerialTaskExecuteVO executeVO);

    /**
     * 启动单一的外部流程或内部流程
     * @param startVO 接口参数
     * @return 启动结果
     */
    @RequestMapping(value = "/workflow/process/simple/start", method = RequestMethod.POST)
    Wrapper<SimpleTaskCompleteVO> startSimpleProcess(@RequestBody @Valid TaskStartVO startVO);

    /**
     * 启动单一的外部流程或内部流程，并执行第一个步骤
     * @param startVO 接口参数
     * @return 执行结果
     */
    @RequestMapping(value = "/workflow/process/simple/start/exec/first", method = RequestMethod.POST)
    Wrapper<SimpleTaskCompleteVO> startSimpleProcessThenCompleteFirstTask(@RequestBody @Valid TaskStartVO startVO);

    /**
     * 执行单一的外部流程、或内部流程
     * @param executeVO 接口参数
     * @return 执行结果
     */
    @RequestMapping(value = "/workflow/process/simple/exec", method = RequestMethod.POST)
    Wrapper<SimpleTaskCompleteVO> completeSimpleTask(@RequestBody @Valid TaskExecuteVO executeVO);

    /**
     * 查询流程参数(dataId)列表
     * @param queryVO 接口参数
     * @return 参数列表
     */
    @RequestMapping(value = "/workflow/process/data", method = RequestMethod.POST)
    Wrapper<List<Long>> findProcessDataIds(@RequestBody @Valid ProcessDataQueryVO queryVO);

    /**
     * 查询复杂流程的任务定义
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/workflow/process/query/complex", method = RequestMethod.POST)
    Wrapper<ComplexTaskDefVO> findComplexTaskDefinitions(@RequestBody @Valid ComplexProcessQueryVO queryVO);

    /**
     * 查询复杂流程的任务定义（多个会员角色）
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/workflow/process/query/complex/roles", method = RequestMethod.POST)
    Wrapper<ComplexTaskDefVO> findComplexTaskDefinitions(@RequestBody @Valid ComplexProcessWithRolesQueryVO queryVO);

    /**
     * 查询单一的外部流程的定义
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/workflow/process/query/external", method = RequestMethod.POST)
    Wrapper<SimpleProcessDefVO> findSimpleExternalTaskDefinitions(@RequestBody @Valid ExternalProcessQueryVO queryVO);

    /**
     * 查询单一的外部流程的定义（多个会员角色）
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/workflow/process/query/external/roles", method = RequestMethod.POST)
    Wrapper<SimpleProcessDefVO> findSimpleExternalTaskDefinitions(@RequestBody @Valid ExternalProcessWithRolesQueryVO queryVO);

    /**
     * 查询单一的内部流程的定义
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/workflow/process/query/internal", method = RequestMethod.POST)
    Wrapper<SimpleProcessDefVO> findSimpleInternalTaskDefinitions(@RequestBody @Valid InternalProcessQueryVO queryVO);

    /**
     * （各种流程通用）根据任务Id，（异步）删除流程实例
     * @param taskIdVO 接口参数
     */
    @RequestMapping(value = "/workflow/process/instance/delete", method = RequestMethod.POST)
    void deleteProcessInstance(@RequestBody @Valid TaskIdVO taskIdVO);
}
